<template>
	<view class="home-page">
		<!-- 顶部导航栏 -->
		<view class="top-nav">
			<view class="nav-title">合同管理系统</view>
		</view>

		<!-- 用户信息 -->
		<view class="user-info">
			<view class="avatar">
				<i class="fa fa-user-circle"></i>
			</view>
			<view class="user-detail">
				<view class="user-name">管理员</view>
				<view class="user-role">系统管理员</view>
			</view>
			<view class="user-actions">
				<view class="action-btn" @click="handleSetting">
					<i class="fa fa-cog"></i>
				</view>
				<view class="action-btn" @click="handleHelp">
					<i class="fa fa-question-circle"></i>
				</view>
			</view>
		</view>

		<!-- 功能卡片 -->
		<view class="function-cards">
			<view class="card-row">
				<view class="function-card" @click="navigateTo('合同管理')">
					<view class="card-icon">
						<i class="fa fa-file-text-o"></i>
					</view>
					<view class="card-name">合同管理</view>
				</view>
				<view class="function-card active" @click="navigateTo('报税管理')">
					<view class="card-icon">
						<i class="fa fa-calculator"></i>
					</view>
					<view class="card-name">报税管理</view>
				</view>
			</view>
			<view class="card-row">
				<view class="function-card" @click="navigateTo('客户管理')">
					<view class="card-icon">
						<i class="fa fa-users"></i>
					</view>
					<view class="card-name">客户管理</view>
				</view>
				<view class="function-card" @click="navigateTo('统计分析')">
					<view class="card-icon">
						<i class="fa fa-bar-chart"></i>
					</view>
					<view class="card-name">统计分析</view>
				</view>
			</view>
		</view>

		<!-- 快捷操作 -->
		<view class="quick-actions">
			<view class="section-title">
				<text>快捷操作</text>
			</view>
			<view class="actions-grid">
				<view class="action-item" @click="handleNewContract">
					<view class="action-icon">
						<i class="fa fa-plus"></i>
					</view>
					<view class="action-name">新增合同</view>
				</view>
				<view class="action-item" @click="handleBatchTax">
					<view class="action-icon">
						<i class="fa fa-batch"></i>
					</view>
					<view class="action-name">批量报税</view>
				</view>
				<view class="action-item" @click="handleNewCustomer">
					<view class="action-icon">
						<i class="fa fa-user-plus"></i>
					</view>
					<view class="action-name">新增客户</view>
				</view>
				<view class="action-item" @click="handleReport">
					<view class="action-icon">
						<i class="fa fa-file-text"></i>
					</view>
					<view class="action-name">报表中心</view>
				</view>
			</view>
		</view>

		<!-- 待办事项 -->
		<view class="todo-list">
			<view class="section-title">
				<text>待办事项</text>
				<view class="more-btn" @click="handleViewAll">
					<text>查看全部</text>
					<i class="fa fa-angle-right"></i>
				</view>
			</view>
			<view class="todo-items">
				<view class="todo-item" v-for="(item, index) in todoList" :key="index">
					<!-- <view class="todo-icon" :class="getTodoIconClass(item.type)">
						<i :class="item.icon"></i>
					</view> -->
					<view class="todo-content">
						<view class="todo-title">{{ item.title }}</view>
						<view class="todo-time">{{ item.time }}</view>
					</view>
					<view class="todo-action" @click="handleTodoAction(item)">
						<i class="fa fa-angle-right"></i>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 待办事项列表
				todoList: [{
						id: 1,
						title: '科技创新有限公司增值税申报',
						time: '2023-07-15',
						type: 'tax',
						icon: 'fa fa-calculator',
						status: 'pending'
					},
					{
						id: 2,
						title: '未来发展有限公司合同审核',
						time: '2023-07-16',
						type: 'contract',
						icon: 'fa fa-file-text-o',
						status: 'pending'
					},
					{
						id: 3,
						title: '智慧教育科技有限公司社保申报',
						time: '2023-07-17',
						type: 'tax',
						icon: 'fa fa-calculator',
						status: 'pending'
					},
					{
						id: 4,
						title: '健康医疗科技有限公司工商年审',
						time: '2023-07-18',
						type: 'tax',
						icon: 'fa fa-calculator',
						status: 'pending'
					}
				]
			};
		},

		methods: {
			// 导航到功能页面
			navigateTo(functionName) {
				if (functionName === '报税管理') {
					uni.navigateTo({
						url: '/pages/tax/index'
					});
				} else {
					uni.showToast({
						title: `${functionName}功能待开发`,
						icon: 'none',
						duration: 2000
					});
				}
			},

			// 处理设置按钮点击
			handleSetting() {
				uni.navigateTo({
					url: '/pages/common/setting'
				});
			},

			// 处理帮助按钮点击
			handleHelp() {
				uni.navigateTo({
					url: '/pages/common/help'
				});
			},

			// 处理新增合同
			handleNewContract() {
				uni.showToast({
					title: '新增合同功能待开发',
					icon: 'none',
					duration: 2000
				});
			},

			// 处理批量报税
			handleBatchTax() {
				uni.navigateTo({
					url: '/pages/tax/index'
				});
			},

			// 处理新增客户
			handleNewCustomer() {
				uni.showToast({
					title: '新增客户功能待开发',
					icon: 'none',
					duration: 2000
				});
			},

			// 处理报表中心
			handleReport() {
				uni.showToast({
					title: '报表中心功能待开发',
					icon: 'none',
					duration: 2000
				});
			},

			// 处理查看全部待办
			handleViewAll() {
				uni.showToast({
					title: '待办事项列表待开发',
					icon: 'none',
					duration: 2000
				});
			},

			// 处理待办事项操作
			handleTodoAction(item) {
				if (item.type === 'tax') {
					uni.navigateTo({
						url: '/pages/tax/index'
					});
				} else {
					uni.showToast({
						title: '相关功能待开发',
						icon: 'none',
						duration: 2000
					});
				}
			},

			// 获取待办事项图标样式
			getTodoIconClass(type) {
				switch (type) {
					case 'tax':
						return 'tax-icon';
					case 'contract':
						return 'contract-icon';
					default:
						return 'default-icon';
				}
			}
		}
	};
</script>

<style lang="scss" scoped>
	/* 页面容器 */
	.home-page {
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	/* 顶部导航栏 */
	.top-nav {
		height: 100rpx;
		background-color: #4188EF;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 999;

		.nav-title {
			font-size: 36rpx;
			font-weight: 500;
		}
	}

	/* 用户信息 */
	.user-info {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 130rpx 30rpx 30rpx;
		background-color: white;

		.avatar {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			background-color: #4188EF;
			display: flex;
			align-items: center;
			justify-content: center;

			i {
				font-size: 60rpx;
				color: white;
			}
		}

		.user-detail {
			flex: 1;
			margin-left: 30rpx;

			.user-name {
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;
				margin-bottom: 8rpx;
			}

			.user-role {
				font-size: 24rpx;
				color: #666666;
			}
		}

		.user-actions {
			display: flex;

			.action-btn {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				background-color: #f5f5f5;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-left: 20rpx;

				i {
					font-size: 30rpx;
					color: #666666;
				}
			}
		}
	}

	/* 功能卡片 */
	.function-cards {
		padding: 0 30rpx 30rpx;

		.card-row {
			display: flex;
			justify-content: space-between;
			margin-bottom: 30rpx;

			.function-card {
				width: calc(50% - 15rpx);
				height: 200rpx;
				background-color: white;
				border-radius: 16rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
				transition: all 0.3s;

				&.active {
					background-color: #4188EF;
					color: white;
				}

				&:active {
					transform: scale(0.98);
				}

				.card-icon {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					background-color: #f5f5f5;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 20rpx;

					i {
						font-size: 40rpx;
						color: #666666;
					}
				}

				&.active .card-icon {
					background-color: rgba(255, 255, 255, 0.2);

					i {
						color: white;
					}
				}

				.card-name {
					font-size: 30rpx;
					font-weight: 500;
					color: #333333;
				}

				&.active .card-name {
					color: white;
				}
			}
		}
	}

	/* 快捷操作 */
	.quick-actions {
		padding: 0 30rpx 30rpx;

		.section-title {
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;

			text {
				font-size: 30rpx;
				font-weight: 500;
				color: #333333;
			}
		}

		.actions-grid {
			display: grid;
			grid-template-columns: repeat(4, 1fr);
			gap: 20rpx;

			.action-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				background-color: white;
				border-radius: 16rpx;
				padding: 20rpx 0;
				box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);

				&:active {
					transform: scale(0.95);
				}

				.action-icon {
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					background-color: #f5f5f5;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 16rpx;

					i {
						font-size: 30rpx;
						color: #666666;
					}
				}

				.action-name {
					font-size: 24rpx;
					color: #333333;
				}
			}
		}
	}

	/* 待办事项 */
	.todo-list {
		padding: 0 30rpx 30rpx;

		.section-title {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 20rpx;

			text {
				font-size: 30rpx;
				font-weight: 500;
				color: #333333;
			}

			.more-btn {
				display: flex;
				align-items: center;

				text {
					font-size: 24rpx;
					color: #666666;
					margin-right: 8rpx;
				}

				i {
					font-size: 24rpx;
					color: #666666;
				}
			}
		}

		.todo-items {
			.todo-item {
				display: flex;
				align-items: center;
				background-color: white;
				border-radius: 16rpx;
				padding: 20rpx;
				margin-bottom: 20rpx;
				box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);

				.todo-icon {
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-right: 20rpx;

					i {
						font-size: 30rpx;
						color: white;
					}
				}

				.tax-icon {
					background-color: #4188EF;
				}

				.contract-icon {
					background-color: #52C41A;
				}

				.default-icon {
					background-color: #FAAD14;
				}

				.todo-content {
					flex: 1;

					.todo-title {
						font-size: 26rpx;
						color: #333333;
						margin-bottom: 8rpx;
					}

					.todo-time {
						font-size: 22rpx;
						color: #999999;
					}
				}

				.todo-action {
					width: 40rpx;
					height: 40rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					i {
						font-size: 24rpx;
						color: #999999;
					}
				}
			}
		}
	}
</style>